﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeanEngine.Data.Linq.Mapping
{
    /// <summary>
    /// Associates a class with a NxN relationship database table.
    /// </summary>
    /// <remarks>
    ///     The relationship table must have all the primary key columns of both 
    ///     tables with the same name of these tables.
    /// </remarks>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
    public sealed class AssociationTableAttribute : Attribute
    {
        #region Constructor Members

        /// <summary>
        /// Initialize a new instance of System.Data.Linq.Mapping.AssociationTableAttribute class.
        /// </summary>
        public AssociationTableAttribute()
        {
            this.AutoInsert = true;
            this.AutoDelete = true;
        }

        #endregion

        #region PropertyInfo Members

        /// <summary>
        /// Gets or sets the association table name.
        /// </summary>
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the flag indicating if the inclusion of the association records 
        /// is performed automatically after including of the parent rows.
        /// </summary>
        public bool AutoInsert
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the flag indicating if the exclusion of the association records 
        /// is performed automatically after deleting of the parent rows.
        /// </summary>
        public bool AutoDelete
        {
            get;
            set;
        }

        #endregion
    }
}
